﻿using MrPP.UX;
using System;
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
namespace MrPP.SerriedCabinet
{
    public class SearchItem : MonoBehaviour
    {

        [SerializeField]
        private Button _button;
        public Action<int> onClicked {
            get;
            set;
        }

       // [SerializeField]
       // private TextMeshPro _text;
        private CabinetGroup.ItemData data_;
        private int id_ = 0;
        public void setup(int id, CabinetGroup.ItemData data)
        {
            id_ = id;
            data_ = data;
            refresh();
           
        }
        private void refresh()
        {
            //_text.text = id_ +":"+ data_.doc_name;
            _button.text = (id_+1).ToString() + ":" + data_.text;
            _button.refresh();
        }
        public void selected() {
            _button.state = Button.State.Selected;
            //Debug.LogError("!!!!");
            _button.refresh();
        }
        public void release() {
            _button.state = Button.State.Enabled;
            _button.refresh();
        }
        public void doClicked() {
            onClicked?.Invoke(id_);
        }
    }
}